home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: seebs@solutions.solon.com (Peter Seebach)
- Newsgroups: comp.lang.c
- Subject: Re: Schildt <- Advanced Books
- Date: 6 Mar 1996 19:42:33 -0600
- Organization: Usenet Fact Police (Undercover)
- Message-ID: <4hleu9$5ah@solutions.solon.com>
- References: <8BA8405.02C70020DE.uuout@sourcebbs.com> <danpop.825687663@rscernix> <4he6hb$ahn@solutions.solon.com> <danpop.826121528@rscernix>
- NNTP-Posting-Host: solutions.solon.com
-
- In article <danpop.826121528@rscernix>, Dan Pop <danpop@mail.cern.ch> wrote:
- >"%f" might be a typo (yet it was preserved between editions, so maybe
- >it was not a typo :-) but the missing cast _cannot_ be a typo.
-
- Well, maybe a very *large* typo.
-
- >There is nothing subtle here, for someone who knows C (which rules Schildt
- >out :-) size_t is _guaranteed_ not to be defined as int, so using "%d"
- >is plain idiotic. I could understand a "%u", and qualify the author as
- >mildly stupid :-)
-
- I consider a bug subtle if the code is likely to work correctly most of the
- time.
-
- >Every single bit as idiotic as "%d" for size_t. Under special
- >circumstances, both give the "correct" results. At least, sizeof(ptr)
- >doesn't invoke undefined behaviour :-)
-
- Curious; less likely to work, yet more legal. :)
-
- Mostly, I object to the specific explanation offered that the sizeof(ptr)
- thing will correctly get the size of the alleged array.
-
- Hmm. Is it really legal to write just part of an object? Hmm. I suppose
- it is, just not useful.
-
- Actually, come to think of it, the attempt to write sizeof(int *) bytes
- from what is expected to be an array of 6 ints may be undefined; assuming,
- that is, that sizeof(int *) is > 6 * sizef(int).
-
- :)
-
- -s
- --
- Peter Seebach - seebs@solon.com - Copyright 1996 Peter Seebach.
- C/Unix wizard -- C/Unix questions? Send mail for help. No, really!
- FUCK the communications decency act. Goddamned government. [literally.]
- The *other* C FAQ - http://www.solon.com/~seebs/c/c-iaq.html
-